/**
 * Created by chuxin on 2017/2/10.
 */
import axios from "axios";
import qs from "querystring";

// axios.defaults.baseURL = 'http://music.163.com/';
// axios.defaults.headers.common['Access-Control-Allow-Origin'] = '*';
// axios.defaults.headers.post['content-type'] = 'application/jsonp; charset=utf-8';

export function fetch_songs(options) {
    const params = {
        'csrf_token': "",
        'type': 1,
        'offset': 0,
        'limit': 10,
        'total': true
    };

    let data = Object.assign(options, params);
    console.log(data);
    return axios.post('/api/search/get/web', qs.stringify(data));
}

export function fetch_song(musicId) {
    return axios.get(`/api/song/detail?id=${musicId}&ids=%5B${musicId}%5D`);
}

export function fetch_lyric(musicId) {
    return axios.get(`/api/song/lyric?os=pc&id=${musicId}&lv=-1&kv=-1&tv=-1`);
}